

<?php
//测试成功
//增加课程
//    include("./conn.php");
$hostname_conn = "localhost";
$database_conn = "xdq";
$username_conn = "root";//没改的话一般时root
$password_conn = "123456";
//连接MYSQL数据库
$conn = mysqli_connect($hostname_conn, $username_conn, $password_conn,$database_conn)or trigger_error(mysqli_error(),E_USER_ERROR);
mysqli_query($conn,"set names 'utf8mb4'");
//$sql1 = "insert into addLesson values ('88','1','1','6','2020-10-19%2015%3A00%3A50')";
//mysqli_query($conn, $sql1);

$userid = $_POST['userid'];
$lessonid = $_POST['lessonid'];
$slesson = $_POST['slesson'];
$sclass = $_POST['sclass'];
$setTime = $_POST['setTime'];

$sql = "select * from addLesson where lessonid = '$lessonid' and openid = '$userid'";
$result = mysqli_query($conn, $sql);
$data = mysqli_fetch_assoc($result);
echo $setTime;
//echo json_encode($data[name],JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT);
if(empty($data)){
    echo "test";
    $sql1 = "insert into addLesson values ('$userid','$lessonid','$slesson','$sclass','$setTime')";
    mysqli_query($conn, $sql);
}else{
    echo json_encode("yes");
}
//userid=11111&lessonid=1&slesson=1&sclass=1&setTime=2020-11-19%2015%3A00%3A50
?>